﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Reflection;

namespace Factory
{
    public class DataAccess<T> where T : class
    {
        /// <summary>
        /// 单例模式+反射
        /// </summary>
        private DataAccess()
        {

        }
        private static readonly string path = ConfigurationManager.AppSettings["dal"];
        public static T createdal(string type)
        {
            string classname = path + "." + type;
            try
            {
                return (T)Assembly.Load(path).CreateInstance(classname);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}